﻿using codeparser.net.v2.Contracts;

using System;
using System.Xml;

namespace codeparser.net.v2.Entities
{
    /// <summary>
    /// Represents a tag element.
    /// </summary>
    public class TagElement : IXmlWriter
    {
        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        public string Name
        {
            get;
            set;
        }

        /// <summary>
        /// Initializes a new instance of the TagElement type.
        /// </summary>
        /// <param name="name">The name.</param>
        public TagElement(string name)
        {
            // Initialize the fields.
            this.Name = name;
        }

        /// <summary>
        /// Saves the tag element to the specified XML writer.
        /// </summary>
        /// <param name="writer">The XML writer.</param>
        void IXmlWriter.Save(XmlWriter writer)
        {
            // Save the element.
            writer.WriteStartElement("Element");
            {
                writer.WriteAttributeString("Name", this.Name);
            }
            writer.WriteEndElement();
        }
    }
}